package org.example.mybatisdemo.controller;


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@RequestMapping("/user")
@RestController
public class TimeFormatController {

    @RequestMapping("/time")
    @GetMapping("/format-time")
    public String formatTime() {
        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();

        // 定义格式化模式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        // 格式化时间
        String formattedTime = now.format(formatter);

        return formattedTime;
    }
}